<template>
  <div>
    <!-- swiper -->
    <swiper :options="swiperOption" ref="mySwiper">
      <div
        class="swiper-slide"
        v-for="(item, index) in bannerList"
        :key="index"
      >
        <router-link :to="item.path">
          <img :src="item.image_url" alt="" style="display: block" />
        </router-link>
      </div>

      <div class="swiper-pagination" slot="pagination"></div>
      <!-- <div class="swiper-button-prev" slot="button-prev"></div>
      <div class="swiper-button-next" slot="button-next"></div> -->
    </swiper>
  </div>
</template>

<script>
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
export default {
  // name: "swiper",
  components: {
    swiper,
    swiperSlide,
  },
  data() {
    return {
      swiperOption: {
        loop: true,
        autoplay: {
          delay: 3000,
          stopOnLastSlide: false,
          disableOnInteraction: true,
        },
        // 显示分页
        pagination: {
          el: ".swiper-pagination",
          clickable: true, //允许分页点击跳转
        },
        // 设置点击箭头
        // navigation: {
        //   nextEl: ".swiper-button-next",
        //   prevEl: ".swiper-button-prev",
        // },
      },
    };
  },
  props: {
    bannerList: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.swiper;
    },
  },
};
</script>

<style lang="less" scoped>
.swiper-container {
  img {
    background: no-repeat center;
    height: 100%;
    width: 100%;
  }
}
</style>